from app.intapp.common import *
from apscheduler.schedulers.blocking import BlockingScheduler
import threading,subprocess,multiprocessing
def get_process_id(name):
    try:
        child = subprocess.Popen(['pgrep', '-f', name],stdout=subprocess.PIPE, shell=False)
        response = child.communicate()[0]
        return [int(pid) for pid in response.split()]
    except:
        return []
def returndate(rundate):
    if rundate < 60:
        rundate=str(rundate)+"秒"
    elif rundate < 60*60:
        rundate=str(int(rundate/60))+"分钟"+str(int(rundate%60))+"秒"
    elif rundate < 60*60*24:
        m=int(rundate%(60*60))
        if m < 60:
            rundate=str(int(rundate/(60*60)))+"小时"+str(m)+"秒"
        elif m <60*60:
            rundate=str(int(rundate/(60*60)))+"小时"+str(int(m/60))+"分"+str(int(m%60))+"秒"
    else:
        m=int(rundate%(60*60*24))
        if m < 60:
            rundate=str(int(rundate/(60*60*24)))+"天"+str(m)+"秒"
        elif m < 60*60:
            rundate=str(int(rundate/(60*60*24)))+"天"+str(int(m/60))+"分"+str(int(m%60))+"秒"
        elif m < 60*60*24:
            xs=int(m/3600)
            mm=int(m%3600)
            if mm < 60:
                rundate=str(int(rundate/(60*60*24)))+"天"+str(xs)+"小时"+str(mm)+"秒"
            else:
                rundate=str(int(rundate/(60*60*24)))+"天"+str(xs)+"小时"+str(int(mm/60))+"分"+str(int(mm%60))+"秒"
    return rundate